package e.odbo.data.dao.interceptor;

import e.odbo.data.bean.I_BaseBean;
import e.odbo.data.bean.ModifiedLogAble;

import java.util.Date;

public class ModifiedLogInterceptor extends AbstractDAOInterceptor{

    @Override
    public boolean beforeInsert(I_BaseBean obj) {
        ((ModifiedLogAble)obj).setLastModified(new Date());
        return super.beforeInsert(obj);
    }

    @Override
    public boolean beforeUpdate(I_BaseBean obj) {
        ((ModifiedLogAble)obj).setLastModified(new Date());
        return super.beforeUpdate(obj);
    }

    @Override
    public boolean interceptorAble(Class beanClass) {
        return ModifiedLogAble.class.isAssignableFrom(beanClass);
    }
}
